| Einhugur Xml Plugin for Xojo |
|
EinhugurXml.XPathVariableSet Class (console safe)
Class to create set of variables for parameterized XPath queries.
XPath queries may contain references to variables; this is useful if you want to use queries that depend on some dynamic parameter without manually preparing the complete query string, or if you want to reuse the same query object for similar queries.
Variable references have the form $name; in order to use them, you have to provide a variable set, which includes all variables present in the query with correct types. This set is passed to XPathQuery constructor or to EinhugurXml.Node.SelectNodes/EinhugurXml.Node.SelectNode functions.
Object
XPathVariableSet
class EinhugurXml.XPathVariableSet
Constructors
Methods
Add | Adds a variable to the set. |
Set | Sets value of named Boolean variable. |
Set | Sets value of named Double variable. |
Set | Sets value of named XPathNodeSet variable. |
Set | Sets value of named string variable. |
Examples
Example:
var f as FolderItem = SpecialFolder.Resources.Child("xgconsole.xml")
if not f.Exists then
MessageBox("Could not find file xgconsole.xml")
return
end if
using EinhugurXml
try
var document as Document = Document.FromFile(f)
var vars as new XPathVariableSet()
vars.Add("remote", XPathType.TYPE_BOOLEAN)
var queryRemoteTools as new XPathQuery("/Profile/Tools/Tool[@AllowRemote = string($remote)]", vars)
vars.Set("remote", true)
var toolsRemote as XPathNodeSet = queryRemoteTools.EvaluateNodeSet(document)
vars.Set("remote", false)
var toolsLocal as XPathNodeSet = queryRemoteTools.EvaluateNodeSet(document)
ListBox1.RemoveAllRows()
ListBox1.AddRow("---Tools Remote:---")
for each node as XPathNode in toolsRemote.XPathNodes
ListBox1.AddRow(node.Node.Name + ": " + node.Node.Attribute("Filename").AsString())
next
ListBox1.AddRow("---Tools Local:---")
for each node as XPathNode in toolsLocal.XPathNodes
ListBox1.AddRow(node.Node.Name + ": " + node.Node.Attribute("Filename").AsString())
next
catch ex as EinhugurXmlParserException
MessageBox(ex.Message + " - Offset:" + ex.Offset.ToString())
catch ex as EinhugurXPathException
MessageBox(ex.Message + " - Offset:" + ex.Offset.ToString())
end try
Supported Platforms:
macOS Intel 64 bitmacOS Apple SiliconWindows 32 bitWindows 64 bitWindows ARM 64 bitLinux 32 bitLinux 64 bitLinux ARM 32 bitLinux ARM 64 bitiOS